package com.mifengs.mall.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.mifengs.commonbase.util.LogUtil;
import com.mifengs.mall.mqtt.MqttRecvUtil;

/**
 * Created by lynn on 2018/1/29.
 */

public class MqttRecvService extends Service {

    private Thread mThread;

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        LogUtil.i("MqttRecvService:","MqttRecvService start");

        if(mThread!=null){
            mThread.interrupt();
        }

        mThread =  new Thread(new Runnable() {
            @Override
            public void run() {
                MqttRecvUtil.Recv();
            }
        });
        mThread.start();
        return super.onStartCommand(intent, flags, startId);

    }
}
